package com.wjy.game;

import com.wjy.game.service.ClientSocketService;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

import com.wjy.game.viewer.LoginViewer;

import javax.swing.*;

/**
 * 客户端
 * @author Administrator
 */
@SpringBootApplication
public class Client {

    public static void main(String[] args) {
        // 设置 java.awt.headless 属性为 false
        System.setProperty("java.awt.headless", "false");
        ConfigurableApplicationContext context = SpringApplication.run(Client.class, args);
        context.getBean(LoginViewer.class).initUI();
        ClientSocketService connectService = context.getBean(ClientSocketService.class);
        boolean isConnect = connectService.connect();
        if (!isConnect) {
            JOptionPane.showMessageDialog(null, "连接服务器失败！", "提示", JOptionPane.ERROR_MESSAGE);
        }
    }
}
